[GLOBAL entry]           ; making entry point visible to linker
[EXTERN _kernel_main]      ; kmain is defined elsewhere

; setting up the Multiboot header - see GRUB docs for details
MODULEALIGN equ  1<<0                   ; align loaded modules on page boundaries
MEMINFO     equ  1<<1                   ; provide memory map
VIDINFO     equ  1<<2                   ; provide video table
FLAGS       equ  MODULEALIGN | MEMINFO  ; this is the Multiboot 'flag' field
MAGIC       equ  0x1BADB002             ; 'magic number' lets bootloader find the header
CHECKSUM    equ -(MAGIC + FLAGS)        ; checksum required

section .text
align 4

MultiBootHeader:
	dd MAGIC
	dd FLAGS
	dd CHECKSUM
	dd 0			; header_addr
	dd 0			; load_addr
	dd 0			; load_end_addr
	dd 0			; bss_end_addr
	dd 0			; entry_addr
	dd 0			; mode_type	0: linear, 1: EGA
	dd 1024		; width
	dd 768		; height
	dd 32		; depth
 
; reserve initial kernel stack space
STACKSIZE equ 0x8000                  ; that's 32k.
 
entry:
	mov esp, stack+STACKSIZE           ; set up the stack
	push    esp ; Stack pointer
	push eax                           ; pass Multiboot magic number
	push ebx                           ; pass Multiboot info structure
	call  _kernel_main                  ; call kernel proper
 
section .bss
align 4

stack:
	resb STACKSIZE                     ; reserve 32k stack on a doubleword boundary
